﻿@{
    ViewBag.Title = "EditRoute";
    //ViewBag.ErrMessNewRoute = "Маршрут с названием уже существует!";
}
@using System.Diagnostics.Eventing.Reader
@using wne.models
@model wne.models.RouteModel
<script src="/Scripts/Route.js?1"> </script>


@using (Html.BeginForm("EditRoute", "Admin", FormMethod.Post, new { id = "EditRouteForm"}))
{
    <div class="hero-unit row" style="margin: 10px 0 10px 0; padding: 10px 0 10px 10px;">
        <h2>Создание/изменение маршрута</h2>
        <div class="row-fluid">
            <div class="span6">
                <h5>Название маршрута:</h5>
                @*@Html.TextBoxFor(m => m.RouteName, new {style = "margin:0 0 20px 0"})
                    @Html.HiddenFor(m => m.RouteId)*@
                
                <input type="text" style="margin:0 0 0px 0" name="RouteName" id="RouteName" value="@Model.RouteName"/>
                <span id="ErrMessNewRoute" style="color: red; font-size: 11px;">@ViewBag.ErrMessNewRoute</span>
                <script>
                    $('#RouteName').change(function () { $('#ErrMessNewRoute').html(""); });
                </script>
                <input type="hidden" name="RouteId" value="@Model.RouteId"/>
            </div>
            <div class="offset2 span4">
                <h5>Выберете группу для простомтра параметров: </h5>
                <select id="group_select" onchange="toggle_tab();">
                        @if (ViewBag.ListGroups != null)
                        {
                            for (int j = 0; j < ViewBag.ListGroups.Count; j++)
                            {
                                <option value="@ViewBag.ListGroups[j].Id">@ViewBag.ListGroups[j].Name</option>                            
                            }
                        }                        
                </select>
            </div>
        </div>


        <div class="row-fluid">
            <div class="span7" > 
                <div class="row-fluid">
                    <h5>Маршрут:</h5>
                </div>

                @*@Html.TextAreaFor(model => model.RouteString, new {rows = "3"})  *@
                <textarea name="RouteString" class="span12" rows="12">@Model.RouteString</textarea>
                <br/>
                <span style="color: red" id="resultSpan"></span>
            </div>

            <div class="offset1 span4" >
                <div class ="row-fluid">
                    <h5>Параметры группы:</h5>  
                    <div id="myTabContent" class="tab-content">
                        @if (ViewBag.ListGroups != null)
                        {
                            for (int j = 0; j < ViewBag.ListGroups.Count; j++)
                            {
                                <div class="tab-pane" id="@ViewBag.ListGroups[j].Id">
                                    <div class="span11">
                                        <table class="table table-bordered table-condensed">
                                        

                                            @for (int i = 0; i < ViewBag.ListGroups[j].Fields.Count; i++)
                                            {
                                                <tr>
                                                    <td><small>@ViewBag.ListGroups[j].Fields[i].Name</small></td>
                                                </tr>
                                            }
                                        </table>
                                    </div>
                                </div>                            
                            }
                        }     
                     </div>
                </div>
            </div>
        </div>  
        
        <button  class="btn btn-primary" type = "submit">Сохранить</button>
        <button id="RouteCancel" class="btn" type = "button" onclick=" location.href = '/admin/RouteList'">Назад</button>
    </div>
}